bool kmp(char *s)
{
    int len=strlen(s);
    int next[len];
    memset( next , -1 , sizeof(next) );
    for (int i = 1; i < len ; i++) {
        int j = next[i - 1];
        while (j != -1 && s[j + 1] != s[i]) {
            j = next[j];
        }
        if (s[j + 1] == s[i]) {
            next[i] = j + 1;
        }
    }
    return next[len-1] !=-1 &&len%(len-next[len-1]-1)==0;
}

bool repeatedSubstringPattern(char * s)
{
    return kmp(s);
}